package com.example.costumview.customview2;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.graphics.drawable.ShapeDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.costumview.R;

public class Telescope2View extends View {
    private Bitmap bitmap;
    private ShapeDrawable drawable;
    //放大镜的半径
    private static float RADIUS = 80;
    //放大倍数
    private static final int FACTOR=3;
    private final Matrix matrix=new Matrix();

    private float mX=-1, mY=-1;

    public Telescope2View(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setLayerType(LAYER_TYPE_SOFTWARE,null);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//
//        if (mBitmapBG == null){
//            mBitmapBG=Bitmap.createBitmap(getWidth(),getHeight(),Bitmap.Config.ARGB_8888);
//            Canvas canvasBG=new Canvas(mBitmapBG);
//            canvasBG.drawBitmap(mBmp,null,new Rect(0,0,getWidth(),getHeight()),mPaint);
//        }
//
//        if (mX!=-1 && mY!=-1){
//            mPaint.setShader(new BitmapShader(mBitmapBG,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT));
//            canvas.drawCircle(mX, mY, mRadius, mPaint);
//        }


    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        final int x = (int) event.getX();
        final int y = (int) event.getY();
        //这个位置表示的是绘制Shader的起始位置
//        matrix.setTranslate(RADIUS-x);

        return super.onTouchEvent(event);
    }
}
